#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

#define ISLESS(a, b) if ((a) != (b)) return (a) < (b)
#define ISGREATER(a, b) if ((a) != (b)) return (a) > (b)

class Book 
{
public:
	int m_height;
	int m_width;
	int m_value;
	int m_initialIndex;
	Book(int h, int w, int v, int ind) : 
		m_height(h),
		m_width(w),
		m_value(v),
		m_initialIndex(ind) {}
};



bool booksValueGreater(const Book &a, const Book &b)
{
	return a.m_value > b.m_value;
}

class BookSelection
{
	int totalHeight;
	int totalWidth;
	vector<Book> books;
	vector<int> heights;
	int count;
	int bestPoints;
	vector<int> bestHeights;
	vector<int> result;
	vector<int> bestResult;

	int GetPoints()
	{
		vector<int> heights = this->heights;
		sort(heights.begin(), heights.end());
		int shelvesCount = heights.size();
		vector<int> widths(shelvesCount, 0);
		result = vector<int>(books.size(), -1);
		int points = 0;

		for (int i = 0; i < books.size(); ++i) {
//			if (books[i].m_width > 400) continue;

			for (int j = 0; j < shelvesCount; ++j) {
				if (heights[j] >= books[i].m_height
						&& widths[j] + books[i].m_width <= totalWidth) {
					widths[j] += books[i].m_width;
					result[books[i].m_initialIndex] = j;
					points += books[i].m_value;
					break;
				}
			}
		}
/*
		for (int i = 0; i < widths.size(); ++i)
			cerr << widths[i] << (i + 1 < widths.size() ? " " : "\n");
*/
		return points;
	}

	void Rec(int filledHeight, int lastHeight)
	{
		int maxHeight = 120;
		int heightStep = max(1, (int)((maxHeight - lastHeight) * (double)(totalHeight - filledHeight) / totalHeight / 2));
		int noRec = true;
		for (int curHeight = lastHeight; curHeight <= maxHeight; curHeight += heightStep) {
			if (filledHeight + curHeight + 10 <= totalHeight) {
				noRec = false;
				heights.push_back(curHeight);
				Rec(filledHeight + curHeight + 10, curHeight);
				heights.pop_back();
			}
		}

		if (noRec) {
			if (totalHeight - filledHeight - 10 > 0) {
				heights.push_back(totalHeight - filledHeight - 10);
			}

			++count;
/*
			for (int i = 0; i < heights.size(); ++i) {
				cerr << heights[i] << (i + 1 < heights.size() ? " " : "\n");
			}
*/
			int points = GetPoints();

//			cerr << "points = " << points << endl;

			if (points > bestPoints)
			{
				bestPoints = points;
				bestHeights = heights;
				bestResult = result;
			}

			if (totalHeight - filledHeight - 10 > 0) {
				heights.pop_back();
			}

//			cerr << endl;
		}
	}

public:

	vector <int> arrange(int H, int W, vector <int> bookHeights, vector <int> bookWidths, vector <int> bookValues) {
		books.clear();
		for (int i = 0; i < bookHeights.size(); ++i) {
			books.push_back(Book(bookHeights[i], bookWidths[i], bookValues[i], i));
			cerr << bookHeights[i] << "\t" << bookWidths[i] << "\t" << bookValues[i] << endl;
		}

		sort(books.begin(), books.end(), booksValueGreater);

		totalHeight = H;
		totalWidth = W;

		count = 0;
		bestPoints = 0;
		bestResult = vector <int>(books.size(), -1);
		Rec(0, 20);
		cerr << "count = " << count << endl;
		cerr << "bestPoints = " << bestPoints << endl;

		
		return bestResult;
	}

};

int nextInt()
{
	int n;
	cin >> n;
	return n;
}

void println(int n)
{
	cout << n << endl;
}

int main()
{
	int H = nextInt();
    int W = nextInt();
    int X = nextInt();
	vector<int> bookHeights(X);
    for(int i = 0; i<X; i++)
      bookHeights[i] = nextInt();
	vector<int> bookWidths(X);
    for(int i = 0; i<X; i++)
      bookWidths[i] = nextInt();
	vector<int> bookValues(X);
    for(int i = 0; i<X; i++)
      bookValues[i] = nextInt();
	BookSelection bs;
    vector<int> ret = bs.arrange(H, W, bookHeights, bookWidths, bookValues);
    for(int i = 0; i<X; i++)
      println(ret[i]);
	return 0;
}
